<template>
	<van-popup v-model="visible" round position="bottom" get-container="#app">
		<van-datetime-picker
			v-model="currentDate"
			:type="type"
			title="选择年月日"
			:min-date="minDate"
			:max-date="maxDate"
			@confirm="confirm"
			@cancel="cancel"
		/>
	</van-popup>
</template>
<script>
export default {
	props: {
		value: {
			type: [Date, String],
			default: () => new Date()
		},
		type: {
			type: String,
			default: "date"
		},
		minDate: Date,
		maxDate: Date
	},
	data() {
		return {
			visible: false,
			currentDate: this.value
		};
	},
	methods: {
		open() {
			this.visible = true;
		},
		confirm(v) {
			this.$emit("input", v);
			this.$emit("confirm", v);
			this.cancel();
		},
		cancel() {
			this.visible = false;
		}
	}
};
</script>
